package client

import (
	"testing"
)

const (
	TestCACert = `-----BEGIN CERTIFICATE-----
MIIC0jCCAbygAwIBAgIRAKmQU1XP3XW8ONTT7HQ9x+gwCwYJKoZIhvcNAQELMBQx
EjAQBgNVBAoTCWludGVybG9jazAeFw0xNjAyMjYyMjU0MDBaFw0xOTAyMTAyMjU0
MDBaMBQxEjAQBgNVBAoTCWludGVybG9jazCCASIwDQYJKoZIhvcNAQEBBQADggEP
ADCCAQoCggEBALlWkKybRVQT3eRuuG+XuSz68dFZ8PN/NRIhJV8+nlwG2vu3Dy9S
hjGBPYyoMaIBYOahHuGhNMQuMgkforobeyJL2XUc31kgL3Beb7q4CqpUiWcwmI1w
zxw4Nfc1u1cORLo8nJvFIZ7V2qqJJp0bv/uZlb6Liuf8vtykmA7Qmr3Nixod71jY
jkZIxqz9U7q5bFBDxUw4oEb+UFA4kUdf71N+1cyn5IXN2QrFftpl31s5Xz0yrQlv
FUzEBJOof9jAF3ntHAus7IVoL9DrpKwmJ1w6zhilItku42jNZRPYDLQcf/wugkZS
JREN7x8VSz6hTpeUd5KlWvHB4ng+OCfdBQ8CAwEAAaMjMCEwDgYDVR0PAQH/BAQD
AgCsMA8GA1UdEwEB/wQFMAMBAf8wCwYJKoZIhvcNAQELA4IBAQAeLsLVHWBcfRUO
6zMOGR2yv3L40RMmwGTyAh/9VMvkx9zSFvEa7ilrsD6In5HLTCVtIc//9/UaCgA2
xmnAWDiWbNcAHRn2ZOOvXkqVS7u7kdvSL+IGqEwQxdxx/WPkMpFBUKxsEaYGHmQc
L6cVDa7wg71DhpUbYelE/0x/28UTkswV4sLanXPJGlX4ZYvJ/POHrFlqZeJaYioP
TLOzQuZya72rhXmsElY0SlSVWBFaDo2+wJ688tfAAc3T+3GqZh17ArNpSUB/rsNE
TnEEMq7EDu3adFkocNW2L4Jp3Ny0oSBVoTX3NwF/fnld8qsNbW6qICCxTHJQyKRH
KyxQJWIx
-----END CERTIFICATE-----`

	TestCert = `-----BEGIN CERTIFICATE-----
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SalYXQH9evunLcf
I5NX7rtJXC7DCbn63ynHeY0gw9mw+qLNCinhJ5pgmij7LpDpQVcVxEBMDA3p5GH0
IMID7l9/wnld6f07xbfLY9mzBoMLtxJCTmzvRPlQr/40TxCbOUI+/pLFb27gZK97
TOKaSksa/82MzquTkhcJYrkCgYEAzI/2eyA3U8a4F7IQCkLPgrVl8bxx/SLf3H3b
ZKvvVlR35qiYnl65Wo/1FCAMb7C7BCxffTn/SMeOBl82I8wOyfOP34NIvOHEY2uy
GtJx1bl69MMM9zINmpJqa7AH3umIWibABThyvZCsdmmrF+QH3mNAjQyZd4SMF5rK
knwaojkCgYAkhVol4h1dLhMaY/K6ttAAg/d6RuBVovsKnbXFzxUgHYUWm6pjWryK
iaKXFTXXkeGoX+NuQwL98CmLgFOgWo3P90r0SDsN9xqi4+MLiY9yzHAa+I5Qzt/k
eT0pvpz6WapVa/sXPmjZF2N/3AvCUGvrwCiOMV+yeYReJIRC0jVcSQ==
-----END RSA PRIVATE KEY-----`
)

func TestGetTLSConfig(t *testing.T) {
	cfg, err := GetTLSConfig(
		[]byte(TestCACert),
		[]byte(TestCert),
		[]byte(TestKey),
		true,
	)

	if err != nil {
		t.Fatal(err)
	}

	if cfg == nil {
		t.Fatal("unexpected nil TLS config")
	}

	if len(cfg.Certificates) != 1 {
		t.Fatal("expected certificate in TLS config")
	}
}
